﻿using System.Configuration;
using System.Web.Configuration;

namespace Salient.Web.Administration.Security.Wizard
{
    public partial class wizardProviderInfo : WebAdminUserControl
    {
        private string ApplicationPath
        {
            get { return (string) Session["WebAdminApplicationPath"]; }
        }

        public void Page_Load()
        {
            System.Configuration.Configuration config = ((WebAdminPage) Page).OpenWebConfiguration(ApplicationPath);
            var membershipSection = (MembershipSection) config.GetSection("system.web/membership");
            var roleManagerSection = (RoleManagerSection) config.GetSection("system.web/roleManager");
            var connectionStringSection = (ConnectionStringsSection) config.GetSection("connectionStrings");

            string defaultProvider = membershipSection.DefaultProvider;
            string connectionStringName =
                membershipSection.Providers[defaultProvider].Parameters["connectionStringName"];
            if (defaultProvider == roleManagerSection.DefaultProvider &&
                connectionStringName == roleManagerSection.Providers[defaultProvider].Parameters["connectionStringName"])
            {
                label1.Text = defaultProvider;
            }
            else
            {
                label1.Text = (string) GetLocalResourceObject("AdvancedSettings");
            }
        }
    }
}